package Iterator;

import java.util.Iterator;

public class DinnerShop {
    private static final int MAX_ITEMS=4;
    int index=0;
    Menu[] MenuItems;
    public DinnerShop(){
        MenuItems = new Menu[MAX_ITEMS];
        addItem("浪漫晚餐",299);
        addItem("小龙虾",99);
        addItem("鱿鱼",49);
        addItem("扇贝",89);
    }
    public void addItem(String name,double price){
        Menu menu=new Menu(name,price);
        if (index>=MAX_ITEMS){
            System.out.println("菜单页满了");
        }else{
            MenuItems[index]=menu;
            index++;
        }
    }
    public Iterator createIterator(){
        return new DinnerMenuIterator(MenuItems);
    }
}
